package com.cvicse.jrcompetition01.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cvicse.jrcompetition01.service.DepartmentService;
import com.cvicse.jrcompetition01.service.MechanismContactService;
import com.cvicse.jrcompetition01.service.MechanismDepartmentService;
import com.cvicse.jrcompetition01.service.MechanismService;
import org.springframework.web.bind.ServletRequestUtils;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

public class BaseController {
    @Resource
    HttpServletRequest req;

    @Resource
    MechanismService mechanismService;

    @Resource
    DepartmentService departmentService;

    @Resource
    MechanismContactService mechanismContactService;

    @Resource
    MechanismDepartmentService mechanismDepartmentService;


    /**
     * 根据前端传入的size、current参数创建满足前端条件的Page对象
     * @return Page 是mybatisplus的分页对象
     */
    public Page getPage() {
        //为了分页功能的正常，要进行default设置
        int current = ServletRequestUtils.getIntParameter(req, "current", 1);
        int size = ServletRequestUtils.getIntParameter(req, "size", 10);

        return new Page(current, size);
    }

}
